package pinboard.dataLayer.binPack;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

class ObjectPackager {
    final protected String defaultCharsetName = "utf8";
    protected PackAttributeCache markCache = null;

    protected static boolean isSimple(Class<?> tClass) {
        if (tClass == byte.class
                || tClass == String.class
                || tClass == int.class
                || tClass == float.class
                || tClass == long.class
                || tClass == double.class) {
            return true;
        } else {
            return false;
        }
    }

    protected Class<?> getFirstArgClass(Type genericFieldType) {
        if (genericFieldType instanceof ParameterizedType) {
            ParameterizedType aType = (ParameterizedType) genericFieldType;
            Type[] fieldArgTypes = aType.getActualTypeArguments();
            Class<?> fieldArgClass = (Class<?>) fieldArgTypes[0];
            return fieldArgClass;
        }
        return null;
    }
}
